package org.jeecg.modules.test.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.api.vo.CorrespondingFiledTestClassOneVO;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.test.entity.CorrespondingFiledTestClassThreeParams;
import org.jeecg.modules.test.entity.CorrespondingFiledTestClassTwoParams;
import org.jeecg.modules.test.entity.HeightLevelBadThing;
import org.jeecg.modules.test.service.IHeightLevelBadThingService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ZhangYu
 * @date 2023/9/24 23:45
 * @description 测试用户关联坏事
 */
@Api(tags = "测试用户关联坏事")
@RestController
@RequestMapping("/height/level/bad/thing")
public class HeightLevelBadThingController extends JeecgController<HeightLevelBadThing, IHeightLevelBadThingService> {

    @Resource
    private IHeightLevelBadThingService heightLevelBadThingService;

    /**
     * 测试线程池
     *
     * @return 测试结果
     */
    @ApiOperation("测试线程池")
    @PostMapping("/test/thread/pool")
    public Result<List<Integer>> testThreadPool() {
        List<Integer> testThreadPool = heightLevelBadThingService.testThreadPool();
        return Result.OK(testThreadPool);
    }

    /**
     * 测试单线程
     *
     * @return 测试结果
     */
    @ApiOperation("测试单线程")
    @PostMapping("/single/thread")
    public Result<List<Integer>> singleThread() {
        List<Integer> singleThread = heightLevelBadThingService.singleThread();
        return Result.OK(singleThread);
    }

    /**
     * 测试多个类转换到一个类
     *
     * @param correspondingFiledTestClassTwoParams   测试字段匹配二类
     * @param correspondingFiledTestClassThreeParams 字段转换测试3
     * @return 测试结果
     */
    @ApiOperation("测试单线程")
    @GetMapping("/more/to/single")
    public Result<CorrespondingFiledTestClassOneVO> moreToSingle(CorrespondingFiledTestClassTwoParams correspondingFiledTestClassTwoParams, CorrespondingFiledTestClassThreeParams correspondingFiledTestClassThreeParams) {
        CorrespondingFiledTestClassOneVO correspondingFiledTestClassOne;
        try {
            correspondingFiledTestClassOne = heightLevelBadThingService.moreToSingle(correspondingFiledTestClassTwoParams, correspondingFiledTestClassThreeParams);
        } catch (Exception e) {
            throw new JeecgBootException("出现异常", e);
        }
        return Result.OK(correspondingFiledTestClassOne);
    }

}
